package com.tianji.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ZhangSanServlet
 */
public class ZhangSanServlet1 extends HttpServlet {
	
	@Override
		protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			// TODO 自动生成的方法存根
		//	super.service(req, resp);
		resp.setContentType("text/html");
		resp.setCharacterEncoding("utf-8");
		PrintWriter out = resp.getWriter();
		if (req.getMethod().equals("GET")) {
			out.println("大家好我是财神");
		}
		if (req.getMethod().equals("POST")) {
			out.println("POST请求");
		}
		out.flush();
		out.close();
		}
	
	
	
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ZhangSanServlet1() {
        super();
        // TODO Auto-generated constructor stub
    }
    
    

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
//	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		// TODO Auto-generated method stub
//		//response.getWriter().append("Served at: ").append(request.getContextPath());
//		response.setCharacterEncoding("UTF-8");//设置输出内容的编码格式
//		response.setContentType("text/html");//设置输出的文件类型
//		PrintWriter out = response.getWriter();
//		out.println("<!DOCTYPE html>");
//		out.println("<HTML>");
//		out.println("<HEAD><meta charset='UTF-8'><title>月老登场</title></HEAD>");
//		out.println("<BODY>大家好，我是月老儿。是天界专管婚姻的媒神。<br/>" + "俗谚：“千里姻缘一线牵，无缘对门不相识”。<br/>"
//				+ "大家以后有什么婚姻方面的问题都可以来咨询我,我一定会对大家：知无不言，言无不尽！<br/>"
//				+ "另外大家一定要记住我的昵称:yueLao,咨询我的地址是：http://localhost:8080/TianJi/yueLao。</BODY>");
//				out.println("</HTML>");
//				out.flush();
//				out.close();// 关闭输出流
//
//	
//	
//	}
//
//	/**
//	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
//	 */
//	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		// TODO Auto-generated method stub
//		doGet(request, response);
//	}

}
